package com.liangdemo.web.easy_poi;

import com.liangdemo.web.Service.UserService;
import com.liangdemo.web.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 导出测试
 * @Name LiangErLe
 * @date 2022/6/27 10:38
 */
@Controller
@RequestMapping("/poi")
@ResponseBody
public class Poi {
    @Autowired
    private UserService userService;
    @GetMapping("/list")
    public  void  test(HttpServletResponse response){
        List<User> userList = userService.list();
        //导出excel
        OfficeExportUtil.exportExcel(OfficeExportUtil.getWorkbook("大标题", "页签名", User.class, userList), "导出文件名", response);

    }
}
